#define DEBUG
#include <cstdio>
#include <cstring>

using namespace std;

const int maxn=500000, mods=998244353;

long long pow[maxn+1];

long long max(int a, int b) {
  return a>b ? a : b;
}

void initPow(long long n) {
  pow[0] = 1;
  for (long long i=1; i<=n; i++) {
    pow[i] = (pow[i-1]*10)%mods;
  }
}

void readBigNum(int a[]) {
  char c;
  for (c=getchar(); c<'0' || c>'9'; c=getchar());
  a[0] = 0;
  for (; c>='0' && c<='9'; c=getchar()) {
    a[++a[0]] = c-'0';
  }
}

void dec(int a[]) {
  static int t[maxn+1];
  t[0] = a[0];
  for (int i=1; i<=a[0]; i++) {
    t[i] = a[a[0]-i+1];
  }
  t[1]--;
  for (int i=1; i<t[0]; i++) {
    if (t[i]<0) {
      t[i]+=10;
      t[i+1]--;
    } else {
      break;
    }
  }
  t[0] = t[t[0]] ? t[0] : t[0]-1;
  a[0] = t[0];
  for (int i=1; i<=t[0]; i++) {
    a[i] = t[t[0]-i+1];
  }
}

long long solve(int n[]) {
  static long long b[maxn+1];
  b[0] = 0;
  for (int i=1; i<=n[0]; i++) {
    b[i] = (b[i-1]+(45ll*(i-1)*pow[max(i-2, 0)])%mods)%mods;
  }

  static long long buc[11];
  memset(buc, 0, sizeof(buc));
  long long a=0, ans=0;
  for (int i=1; i<=n[0]; i++) {
    for (int x=0; x<n[i]; x++) {
      ans = (ans+((((a+buc[x+1])%mods+x*(n[0]-i))%mods*pow[max(n[0]-i-1, 0)])%mods+b[n[0]-i])%mods)%mods;
    }
    if (n[i]) {
      for (int x=0; x<10; x++) {
	ans = (ans+buc[x]*(n[0]-i)%mods*pow[n[0]-i-1]%mods)%mods;
      }
    }
    a = (a+buc[n[i]+1])%mods;
    for (int x=n[i]; x>=0; x--) {
      buc[x]++;
    }
  }
  return (ans+a)%mods;
}

int main() {
  freopen("pair.in", "r", stdin);
  freopen("pair.out", "w", stdout);

  initPow(maxn);

  int t, id;
  scanf("%d %d", &t, &id);
  for (int ti=1; ti<=t; ti++) {
    static int l[maxn+1], r[maxn+1];
    readBigNum(l);
    dec(l);
    readBigNum(r);
    printf("%lld\n", solve(r)-solve(l));
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
